#ifndef ALFS_LANGUAGE_SUPPORT_BOOL3ENUM_HPP
#define ALFS_LANGUAGE_SUPPORT_BOOL3ENUM_HPP
#include    <alfs/config.hpp>

// File [alfs/language_support/Bool3Enum.hpp].
//
// (c) copyright Alf P. Steinbach 2008.
// Use, modification and distribution are subject to the "New BSD License"
// as listed at <url: http://www.opensource.org/licenses/bsd-license.php>.

#include    <algorithm>     // std::min, std::max

namespace alfs {

    struct Bool3
    {
        enum Enum { no, maybe, yes };

        template< bool x >
        struct FromBool;
    };

    template<>
    struct Bool3::FromBool<false>{ static Bool3::Enum const value = Bool3::no; };

    template<>
    struct Bool3::FromBool<true>{ static Bool3::Enum const value = Bool3::yes; };

    inline Bool3::Enum operator!( Bool3::Enum x )
    {
        return Bool3::Enum( Bool3::yes - x );
    }

    inline Bool3::Enum operator&&( Bool3::Enum a, Bool3::Enum b )
    {
        return std::min( a, b );
    }

    inline Bool3::Enum operator||( Bool3::Enum a, Bool3::Enum b )
    {
        return std::max( a, b );
    }

}  // alfs

#endif
